<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
    request.setCharacterEncoding("UTF-8");
    String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : "";
%>
<!doctype html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>用户管理</title>
    <s:head/>
    <style type="text/css">
        .td_right {
            text-align: right;
        }
    </style>
    <script>
        var contentHtml = "";
        var editor;

        $(document).ready(function () {
// 		var companyType = "${sessionScope.CURRENT_USER.company}";
            var companyType = "${companyType}";
            if (companyType == "CL" || companyType == "CC") {
                $("#account").attr("disabled", true);
                $("#userType").hide();
                $("#type").val("2");
            }


            //初始化表单验证引擎
            $("#userForm").validationEngine("attach", {
                //消息位置
                promptPosition: "bottomRight",
                scroll: false
            });
            //初始化ajaxForm参数
            var options = {
                //提交方式
                type: "POST",
                //提交数据格式
                dataType: "json",
                //在提交之前做的操作
                beforeSubmit: function () {
                    return $("#userForm").validationEngine("validate");
                },
                //成功后做的操作
                success: function (responseText, statusText, xhr, $form) {
                    alert(responseText.msg);
                    location.href = "company-mainUser?dept.id=" + $("#deptId").val();
                }
            };
            $('#userForm').ajaxForm(options);
        });
        function submitTheForm() {
            $("#userForm").submit();
        }

    </script>
</head>
<body class="base_font_size">
<%=htmlData%>
<form name="example" id="userForm" method="post" action="company-saveOrUpdateUser">
    <div class="ui-widget">
        <table class="ui-widget-content" style="width: 100%;">
            <tr>
                <td class="td_right td_right_individualStyle">用户名</td>
                <td colspan="3"><input class="validate[required] input_individualStyle" type="text" id="user_name"
                                       name="user.name" value="${user.name}" style="width:705px;^width:690px;"/>*
                </td>
            </tr>
            <tr>
                <td class="td_right td_right_individualStyle">用户密码</td>
                <td><input class=" input_individualStyle" type="password" name="user.pwd" value="${user.pwd}"/></td>
                <td class="td_right td_right_individualStyle">手机号码</td>
                <td><input class=" input_individualStyle" type="text" name="user.mobile" value="${user.mobile}"/></td>
            </tr>
            <tr>
                <td class="td_right td_right_individualStyle">用户账号</td>
                <td><input class=" input_individualStyle" id="account" type="text" name="user.account"
                           value="${user.account}"/></td>
                <td class="td_right td_right_individualStyle">邮箱地址</td>
                <td><input class=" input_individualStyle" type="text" name="user.email" value="${user.email}"/></td>
            </tr>
            <tr>
                <td class="td_right td_right_individualStyle">用户类型</td>
                <!-- 					<td colspan="3"> -->
                <td>
                    <select style="margin: 5px 5px 0 0;" id="type" name="user.type">
                        <s:if test="user.type==0">
                            <option value="0" selected="selected">系统管理员</option>
                            <option value="1">公司管理员</option>
                            <option value="2">公司普通职员</option>
                        </s:if>
                        <s:elseif test="user.type==1">
                            <option value="0">系统管理员</option>
                            <option value="1" selected="selected">公司管理员</option>
                            <option value="2">公司普通职员</option>
                        </s:elseif>
                        <s:elseif test="user.type==2">
                            <option value="0">系统管理员</option>
                            <option value="1">公司管理员</option>
                            <option value="2" selected="selected">公司普通职员</option>
                        </s:elseif>
                        <s:else>
                            <option value="0">系统管理员</option>
                            <option value="1">公司管理员</option>
                            <option value="2">公司普通职员</option>
                        </s:else>
                    </select>
                </td>
                <td class="td_right td_right_individualStyle">固定电话</td>
                <td><input class=" input_individualStyle" type="text" name="user.telphone" value="${user.telphone }"/>
                </td>
            </tr>
            <!-- 				<tr> -->
            <!-- 					<td class="td_right td_right_individualStyle">手机验证</td> -->
            <!-- 					<td colspan="3"></td> -->
            <!-- 				</tr> -->
            <tr>
                <td colspan="4" align="center" class="bts">
                    <input class="button_individualStyle" type="button" onclick="submitTheForm()" name="btn"
                           value="应用存盘"/>
                    <input class="button_individualStyle" type="button" onclick="javascript:history.back();" name="btn"
                           value="返回"/>
                </td>
            </tr>
        </table>
    </div>
    <input type="hidden" name="dept.id" id="deptId" value="${dept.id}"/>
    <input type="hidden" name="user.id" value="${user.id}"/>
    <input type="hidden" name="user.isabled" value="${user.isabled}"/>
    <input type="hidden" name="user.state" value="${user.state}"/>
</form>
</body>
</html>
